/* vim: set ts=2 et sw=2 cindent fo=qroca: */

package com.globant.google.mendoza.malbec;

/** The buyer address as enter by the user in the place order page.
 */
public final class BuyerAddress implements BuyerInformation {

  /** The address id.
   *
   * This address id can be found using 'view source' in the buyer's shipping
   * address configuration page. It can be -1 for an address used only for the
   * current order.
   */
  private String addressId;

  /** The first line of the buyer's address.
   */
  private String address1;

  /** The second line of the buyer's address.
   */
  private String address2;

  /** The address city.
   */
  private String city;

  /** The address country code.
   */
  private String countryCode;

  /** The address state.
   */
  private String state;

  /** The address zip code.
   */
  private String zipCode;

  /** Creates the data that the buyer posts when adding new addresses.
   *
   * @param theAddressId The address id.  This address id can be found using
   * 'view source' in the buyer's shipping address configuration page. It can
   * be '-1' for an address used only for the current order. It cannot be null.
   *
   * @param theAddress1 The first line of the buyer address. It cannot be null.
   *
   * @param theAddress2 The second line of the buyer address. It cannot be
   * null.
   *
   * @param theCity The address city. It cannot be null.
   *
   * @param theCountryCode The address country code. It cannot be null.
   *
   * @param theState The address state. It cannot be null.
   *
   * @param theZipCode The address zip code. It cannot be null.
   */
  public BuyerAddress(final String theAddressId, final String theAddress1,
      final String theAddress2, final String theCity, final String
      theCountryCode, final String theState, final String theZipCode) {

    if (theAddressId == null) {
      throw new IllegalArgumentException("the address id cannot be null");
    }
    if (theAddress1 == null) {
      throw new IllegalArgumentException("the address 1 cannot be null");
    }
    if (theAddress2 == null) {
      throw new IllegalArgumentException("the address 2 cannot be null");
    }
    if (theCity == null) {
      throw new IllegalArgumentException("the city cannot be null");
    }
    if (theCountryCode == null) {
      throw new IllegalArgumentException("the country code cannot be null");
    }
    if (theState == null) {
      throw new IllegalArgumentException("the state cannot be null");
    }
    if (theZipCode == null) {
      throw new IllegalArgumentException("the zip code cannot be null");
    }

    addressId = theAddressId;
    address1 = theAddress1;
    address2 = theAddress2;
    city = theCity;
    countryCode = theCountryCode;
    state = theState;
    zipCode = theZipCode;
  }

  /** Returns the address id.
   * @return Returns the address id.
   */
  public String getAddressId() {
    return addressId;
  }

  /** Makes the visitor to enter an address.
   * @param visitor The visitor visiting the class.
   */
  public void execute(final BuyerVisitor visitor) {
    visitor.enterAddress(this);
  }

  /**Returns the address1.
   * @return the address1
   */
  public String getAddress1() {
    return address1;
  }

   /**Returns the address2.
   * @return the address2
   */
  public String getAddress2() {
    return address2;
  }

  /**Returns the city.
   * @return the city
   */
  public String getCity() {
    return city;
  }

  /**Returns the countryCode.
   * @return the countryCode
   */
  public String getCountryCode() {
    return countryCode;
  }

  /**Returns the state.
   * @return the state
   */
  public String getState() {
    return state;
  }

  /**Returns the zipCode.
   * @return the zipCode
   */
  public String getZipCode() {
    return zipCode;
  }

}

